package com.banciyuan.bcywebview.base.view.dialog;

import android.app.Dialog;
import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.banciyuan.bcywebview.R;

/**
 * Created by squall on 2015/12/30.
 */
public class WithDrawDialog extends Dialog {


    public WithDrawDialog(Context context) {
        super(context);
    }

    public WithDrawDialog(Context context, int theme) {
        super(context, theme);
    }

    protected WithDrawDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    public static class Builder {
        private Context context;
        private View.OnClickListener comfirmAction;
        private String comfirm_text;
        private String title_text;
        private String titleDescText;
        private Button comfirmBtn;
        private TextView title_tv;
        private TextView titleDescTv;

        public Builder(Context context) {
            this.context = context;
        }

        public Builder setBtnComfirm(View.OnClickListener onClickListener) {
            this.comfirmAction = onClickListener;
            return this;
        }

        public Builder setBtnComfirmText(String text) {
            this.comfirm_text = text;
            return this;
        }

        public Builder setTitleText(String text) {
            this.title_text = text;
            return this;
        }

        public Builder setTitleDescText(String text) {
            this.titleDescText = text;
            return this;
        }

        public WithDrawDialog create() {
            LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            final WithDrawDialog mydialog = new WithDrawDialog(context, R.style.Dialog);
            View layout = inflater.inflate(R.layout.withdraw_dialog, null);
            comfirmBtn = ((Button) layout.findViewById(R.id.post_continues));
            title_tv = (TextView) layout.findViewById(R.id.update_log);
            titleDescTv = (TextView) layout.findViewById(R.id.update_log_desc);
            comfirmBtn.setText(comfirm_text);
            title_tv.setText(Html.fromHtml(title_text));
            titleDescTv.setText(titleDescText);
            comfirmBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (null != comfirmAction)
                        comfirmAction.onClick(v);
                    mydialog.dismiss();
                }
            });
            mydialog.setContentView(layout);
            return mydialog;
        }
    }


}
